<?php 
/**
 * TomatoCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: add.phtml 4700 2010-08-16 16:14:34Z jam-gate.vn $
 * @since		2.0.0
 */
?>
<?php 
$this->headTitle($this->translator('customer_add_page_title'));

$this->headScript()
	->appendFile($this->APP_STATIC_SERVER . '/js/jquery.validate/jquery.validate.min.js')
	->appendFile($this->APP_STATIC_SERVER . '/js/tomato/util.js')
	->appendFile($this->APP_STATIC_SERVER . '/js/jquery.slideviewer/jquery.slideviewer.1.2.js');	
?>
<link media="all" type="text/css" href="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/themes/base/ui.core.css" rel="stylesheet">				
<link media="all" type="text/css" href="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/themes/base/ui.resizable.css" rel="stylesheet">		
<link media="all" type="text/css" href="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/themes/base/ui.dialog.css" rel="stylesheet">
<link media="all" type="text/css" href="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/themes/base/ui.theme.css" rel="stylesheet">

<script language="JavaScript" type="text/JavaScript" src="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/ui.core.js"></script>		
<script language="JavaScript" type="text/JavaScript" src="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/ui.draggable.js"></script>		
<script language="JavaScript" type="text/JavaScript" src="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/ui.resizable.js"></script>
<script language="JavaScript" type="text/JavaScript" src="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/ui.dialog.js"></script>
<style>
	.dialog_search_info{
		display:none;
	}
	.dialog_search_info table{
		border-left: 1px solid  #A9A9A9;
	}
	.dialog_search_info thead th{
		color:black;
		background: #CCCCCC;
		border-top: 1px solid  #A9A9A9;
	}
	.dialog_search_info tbody td, th{
		background:	#F0FFFF;
		color: 	#2F4F4F;
		border-right: 1px solid  #A9A9A9;
		border-bottom: 1px solid #A9A9A9;
	}
</style>

<script language="javascript">
	function <?php echo $this->fnOpenDialog;?>(){		
		$("#<?php echo $this->tableId;?>_container").dialog({
			title: '<?php echo $this->translator($this->title);?>',
			dialogClass: 't_a_ui_dialog',
			position: 'center',
			modal: true,
			closeOnEscape: false,
			resizable: true,
			width:  <?php echo $this->dialogWidth?>,
			height: <?php echo $this->dialogHeight?>,
			"buttons": { 
					"<?php echo $this->translator("core_ok","core");?>": function() {
						$("#<?php echo $this->tableId;?>").find("input:checkbox").attr("checked",false);						
						$("#<?php echo $this->tableId;?>").find("input:radio").attr("checked",false);
						$(this).dialog("close");
						<?php if($this->fnTableAction):?>
							<?php echo $this->fnTableAction;?>();
						<?php endif;?> 
					}
			}, 					
			close: function(event, ui) {
				$("#<?php echo $this->tableId;?>").find("input:checkbox").attr("checked",false);						
				$("#<?php echo $this->tableId;?>").find("input:radio").attr("checked",false);
				$(this).dialog('destroy');                       
			},
			open: function(event, ui){	
				$('input#dialog_search_input_<?php echo $this->tableId;?>').quicksearch('table#<?php echo $this->tableId;?> tbody tr');							
				$(".ui-dialog-buttonpane").find("button").each(function(){
					$(this).css("width","80px");
					$(this).css("padding","6px");
					$(this).css("background","#D2691E");
				});	
			}
		});		
	}	
</script>
<a href="javascript:void(0)" onclick="<?php echo $this->fnOpenDialog;?>();" title="<?php echo $this->translator("core_search","core");?>"><img src="<?php echo $this->APP_STATIC_SERVER;?>/images/icons/find_table.gif"></img></a>
<div id="<?php echo $this->tableId;?>_container" class="dialog_search_info">
	<input type="text" id="dialog_search_input_<?php echo $this->tableId;?>" title="Tìm kiếm" autofocus size="40" style="border:	1px solid #2F4F4F;"/>
	<table id="<?php echo $this->tableId;?>" style="width:<?php echo $this->dialogWidth-25;?>px;margin-top:10px;">
		<thead>
			<tr class="<?php echo $this->tableId;?>_table_header">
				<?php foreach($this->arrHeader as $itemHeader=>$widthItem):?>
				<th width="<?php echo $widthItem;?>"><?php echo $itemHeader;?></th>
				<?php endforeach;?>
				<?php if($this->typeTableAction):?>
					<th>#</th>
				<?php endif;?>
			</tr>
		</thead>
		<tbody>
			<?php if($this->rows):
				foreach($this->rows as $item):?>
					<tr>
						<?php foreach($this->arrHeader as $itemHeader=>$widthItem):?>
						<td width="<?php echo $widthItem;?>"><?php echo $item->$itemHeader;?></td>
						<?php endforeach;?>
						<?php if($this->typeTableAction):?>
							<td style="text-align:center;padding-left:5px;padding-right:5px;">
								<input class="<?php echo $this->classInput;?>" type="<?php echo $this->typeTableAction;?>" onclick="<?php echo $this->fnTableActionRow;?>();"></input>
							</td>
						<?php endif;?>
						
					</tr>
			<?php endforeach;?>	
			<?php endif;?>
		</tbody>
	</table>
</div>